package kr.hkit.wordnote.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.wordnote2.R;

public class PlaceholderFragment extends Fragment{
	final static String TAG ="FlipperActivity";
	TextView tv2;
	public static PlaceholderFragment newInstance(int position){
		Log.d(TAG, "newInstance");
		PlaceholderFragment fragment = new PlaceholderFragment();
		Bundle args = new Bundle();
		args.putInt("position", position);
		/*args.putString("engWord", engWord);
		args.putString("korWord", korWord);
		args.putInt("delayTime", delayTime);*/
		fragment.setArguments(args);
		
		return fragment;
	}
	
	@Override
	public void onAttach(Activity activity) {
		Log.d(TAG, "onAttach");
		super.onAttach(activity);
	}
	public PlaceholderFragment(){
		
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		Log.d(TAG, "onCreateView");
		int position = getArguments().getInt("position");
		View rootView = null;
	
		//기본적으로 Viewpager는 현재 보이는 페이지와 양쪽의 페이지를 미리 로딩시켜 놓으므로 각각에 해당하는 3개의 프래그먼트를 준비한다. 
		//그리고 현재 포지션에 따라 전개하는 프래그먼트를 달리하고 번갈아가며 프래그먼트를 재사용한다.
		if(position == 0){
			rootView = inflater.inflate(R.layout.flipperfragment00, container, false);
		}else if((position%3) == 0 && position != 0){
			rootView = inflater.inflate(R.layout.flipperfragment01, container, false);
		}else if((position%3) == 1){
			rootView = inflater.inflate(R.layout.flipperfragment02, container, false);
		}else if((position%3) == 2){
			rootView = inflater.inflate(R.layout.flipperfragment03, container, false);
		}
		return rootView;
	}
	
	@Override
	public void onStart() {
		Log.d(TAG, "onStart");
		super.onStart();
	
	}
}
